
// #ifndef VUE3
import Vue from 'vue'

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif
uni.addInterceptor('request', {
  invoke(args) {
    // request 触发前拼接 url 
    args.url = 'http://localhost:8080/' + args.url;

    // 添加 Authorization 请求头
    let token = uni.getStorageSync('token');  // 替换为你的 token
	// token="eyJhbGciOiJSUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNjg4OTgxOTAzfQ.tNqcms1SH_cHGnS1OSFp-hg2SIRPKoMUkhrKfLNXSu2hBRf64OMA2b-_gbTIhAaGtIRePGJSHB3295Yu6chgaw9stVkPLnNw0Szsv8kuPm1AnnISw_WYycnBp7b6A4eDg2VakoS30RxvVRIfs6uRgHzIvg_25jYjgDxNjAmQzoA"
    if (token) {
      if (!args.header) {
        args.header = {};
      }
      args.header['Authorization'] = token;
	  console.log(token)
    }
  },
  success(args) {
    // // 请求成功后，修改 code 值为 1
    // args.data.code = 1;
  },
  fail(err) {
    console.log('interceptor-fail', err);
  },
  complete(res) {
    console.log('interceptor-complete', res);
  }
});